from collections import deque

#运行比列表更快
a=deque([1,2,3,4])
a.append(5)
print(a)#[1, 2, 3, 4, 5]
a.appendleft(6)  #加在左边
print(a)#  [6, 1, 2, 3, 4, 5]

a.pop()#删除最右边
print(a)
a.popleft()#删除左边
print(a)

a.extend([2,3,4])
print(a)
a.remove(2)
print(a)

a.reverse()#翻转
print(a)

a=sorted(a)#排序
print(a)
a=sorted(a,reverse=True)#降序
print(a)

b=deque([1,2,3,4,5])
b.rotate(2)#元素向右移动两位
print(b)
b.rotate(-3)
print(b)